package com.xinchuang.controller.targetSystem.systems;

import cn.hutool.core.collection.CollectionUtil;
import com.alibaba.fastjson.JSONObject;
import com.xinchuang.common.Result;
import com.xinchuang.common.ResultEnum;
import com.xinchuang.common.ResultUtil;
import com.xinchuang.entity.targetSystem.object.*;
import com.xinchuang.service.targetSystem.SystemElseService;
import com.xinchuang.service.targetSystem.SystemsService;
import com.xinchuang.vo.SystemsDynamicVo;
import com.xinchuang.vo.SystemsIndexPowerVo;
import com.xinchuang.vo.SystemsRangeVo;
import com.xinchuang.vo.SystemsTargetListVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.Value;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;

/**
 * @ClassName
 * @Description:
 * @auther xukl
 * @data 2021/3/29  17:04
 * @Version V1.0
 */
@Api(value = "体系controller", tags = {"体系维护接口"})
@Slf4j
@RestController
@RequestMapping("/systems")
public class SystemsController {

    /**
     * 初始化新增系统
     */
    private final String INIT_ADD = "/init";

    /**
     * 查询类别下拉列表
     */
    private final String SELECT_SYSTEM_PULL_TYPE = "/pull";
    /**
     * 查询待选目标
     */
    private final String SELECT_SYSTEM_WAIT_CHOICE_TARGET = "/findWait";
    /**
     * 更新系统目标选择
     */
    private final String UPDATE_SYSTEM_TARGET_CHOICE = "/updateTargetList";
    /**
     * 查询已选目标
     */
    private final String SELECT_SYSTEM_TARGET_CONFIRM = "/findConfirm";
    /**
     * 查询系统基本信息
     */
    private final String SELECT_SYSTEM_BASE_DATA = "/baseData";
    /**
     * 删除系统基本信息
     */
    private final String DELETE_SYSTEMS_BASE_DATA = "/deleteBaseData";
    /**
     * 指标下列列表
     */
    private final String SELECT_INDEX_PULL = "/indexPull";
    /**
     * 查询体系详细信息
     */
    private final String SELECT_SYSTEM_DETAIL_DATA = "/detailData";
    /**
     * 查询系统列表
     */
    private final String SELECT_SYSTEM_LIST = "/queryList";
    /**
     * 上传目标缩略图
     */
    private final String UPLOAD_TARGET_ICON = "/upload/icon";
    /**
     * 体系关系
     */
    private final String SELECT_RELATION_DATA = "/relationData";

    /**
     * 添加待选目标到系统
     */
    private final String INSERT_INDEX_TARGET_LIST = "/addTargetList";

    /**
     * 查询系统已选信息列表
     */
    private final String SELECT_CONFIRM_DATA_LIST = "/queryConfirmList";

    /**
     * 查询指数列表
     */
    private final String SELECT_INDEX_DATA = "/indexData";

    /**
     * 查询对比指数列表
     */
    private final String SELECT_INDEX_COMPARISON_DATA = "/comparisonData";

    /**
     * 查询系统待选信息列表
     */
    private final String SELECT_WAIT_DATA_LIST = "/queryWaitList";

    /**
     * 查询体系模块基础信息
     */
    private final String SELECT_SYSTEM_BASE_DATA_ONLY = "/queryArchiteture";

    /**
     * 查询类型列表
     */
    private final String SELECT_TYPE_LIST = "/queryTypeList";

    /**
     * 查询类型列表
     */
    private final String SELECT_SYSTEM_CHOOSE_LIST = "/querySystemList";

    /**
     * 操作体系专有属性
     */
    private final String SYSTEMS_ELSE_DATA = "/elseData";

    //独立武汉接口

    /**
     * 查询已选目标列表（武汉）
     */
    private final String SELECTED_TARGET_WUHAN = "/wuhan/querySelected";

    /**
     * 新增体系（武汉）
     */
    private final String INSERT_SYSTEMS = "/wuhan/addSystems";

    /**
     * 查询体系列表（武汉）
     */
    private final String SELECT_SYSTEMS_LIST = "/wuhan/systemsList";

    /**
     * 生成报告
     */
    private final String CREATE_DOC = "/createDoc";

    /**
     * 下载报告
     */
    private final String DOWNLOAD_DOC = "/downDoc";

    /**
     * 目标下拉
     */
    private final String SELECT_TARGET_PULL = "/targetPull";

    /**
     * 体系目标下拉
     */
    private final String SELECT_SYSTEM_TARGETS = "/systemsPull";

    /**
     * 查询体系目标分析能力下拉
     */
    private final String SELECT_SYSTEM_TARGET_POWER = "/sysTargetPowerPull";

    /**
     * 新增打击评估
     */
    private final String ADD_BLOW = "/addBlow";

    /**
     * 体系范围操作
     */
    private final String SYSTEMS_RANGE = "/systemsRange";

    /**
     * 操作作用范围
     */
    private final String SYSTEMS_RANGE_DEL = "/systemRangeDeo";

    /**
     * 体系目标清单
     */
    private final String SYSTEMS_INDEX_TARGET_LIST = "/systemsTargetIndexList";

    /**
     * 体系目标清单排序
     */
    private final String SYSTEM_TARGET_LIST_SORT = "/systemsTargetListSort";

    /**
     * 体系类型指标
     */
    private final String SYSTEMS_TYPE_INDEX = "/systemsTypeIndex";

    /**
     * 体系树
     */
    private final String SYSTEMS_TREE = "/systemsTree";

    /**
     * 体系场景
     */
    private final String SYSTEMS_SCENE = "/systemsScene";

    /**
     * 获取体系场景
     */
    private final String SYSTEMS_SCENE_GET = "/getSystemsScene";

    /**
     * 体系分析目标列表
     */
    private final String SYSTEMS_ANALYSIS_DATA = "/selectSystemsAnalysisData";

    /**
     * 体系分析能力下拉
     */
    private final String SYSTEMS_TARGET_POWER_PULL = "/selectSystemsPowerPull";

    /**
     * 体系分析重置
     */
    private final String SYSTEMS_ANALYSIS_RESTART = "/restartSystemsAnalysis";

    /**
     * 体系分析目标列表
     */
    private final String SYSTEMS_TARGET_POWER_TARGET_LIST = "/selectSystemsPowerTargetList";

    /**
     * 体系分析目标排序
     */
    private final String SYSTEMS_TARGET_POWER_TARGET_SORT = "/selectSystemsPowerTargetSort";

    /**
     * 体系分析目标删除
     */
    private final String SYSTEMS_TARGET_POWER_TARGET_DELETE = "/selectSystemsPowerTargetDelete";

    /**
     * 移动目标清单
     */
    private final String MOVE_SYSTEMS_TARGET_LIST = "/moveSystemsTargetList";

    /**
     * 查询目标清单
     */
    private final String SELECT_SYSTEMS_TARGET_LIST = "/selectSystemsTargetList";

    /**
     * 排序目标清单
     */
    private final String SORT_SYSTEMS_TARGET_LIST = "/sortSystemsTargetList";

    /**
     * 删除目标清单
     */
    private final String DELETE_SYSTEMS_TARGET_LIST = "/deleteSystemsTargetList";

    /**
     * 目标指标分析
     */
    private final String HIT_ANALYSIS = "/hitAnalysis";

    /**
     * 体系分析相关数据
     */
    private final String SAVE_ANALYSIS = "/saveAnalysis";

    /**
     * 场景树
     */
    private final String SCENE_TREE = "/sceneTree";

    /**
     * 场景查询
     */
    private final String SCENE_DATA = "/sceneData";

    /**
     * 更新场景目标
     */
    private final String UPDATE_SCENE_TARGET = "/updateSceneTarget";

    /**
     * 删除场景目标
     */
    private final String DELETE_SCENE_TARGET = "/deleteSceneTarget";

    /**
     * 查询场景子目标下拉
     */
    private final String SELECT_SCENE_SUB_PULL = "/selectSceneSubPull";

    /**
     * 保存场景子目标
     */
    private final String ADD_SCENE_SUB = "/addSceneSub";

    /**
     * 删除场景子目标
     */
    private final String DELETE_SCENE_SUB = "/deleteSceneSub";

    /**
     * 保存场景能力清单
     */
    private final String SAVE_SCENE_INDEX = "/saveSceneIndex";

    /**
     * 战斗部下拉
     */
    private final String PAYLOAD_PULL = "/payloadPull";

    /**
     * 弹型下拉
     */
    private final String MISSILE_PULL = "/missilePull";

    /**
     * 导入场景Excel文档
     */
    private final String EXPORT_SCENE_EXCEL = "/exportExcel";

    /**
     * 获取必达设施
     */
    private final String GET_HIT_TARGET = "/getHitTarget";

    /**
     * 体系分析目标静态分析
     */
    private final String GET_SYSTEMS_TARGET_STATIC_ANALYSE = "/getSystemsTargetStaticAnalyse";

    /**
     * 体系分析目标规律分析停驻目标列表
     */
    private final String GET_RULE_POSTURE_LIST = "/getSystemsRulePostureList";

    /**
     * 体系分析目标规律分析
     */
    private final String GET_RULE_ANALYSE = "/getSystemsRuleAnalyse";

    /**
     * 体系分析目标动态分析
     */
    private final String GET_ACTIVE_ANALYSE = "/getSystemsActiveAnalyse";

    /**
     * 体系分析目标意图分析
     */
    private final String GET_INTENTION_ANALYSE = "/getSystemsIntentionAnalyse";

    /**
     * 体系分析目标关联分析
     */
    private final String GET_RELATION_ANALYSE = "/getSystemsRelationAnalyse";

    /**
     * 体系分析目标整体分析
     */
    private final String GET_OVERALL_ANALYSE = "/getSystemsOverallAnalyse";


    @Resource
    private SystemsService systemsService;

    @Resource
    private SystemElseService systemElseService;

    @ApiOperation(value = "初始化新增系统")
    @GetMapping(INIT_ADD)
    public Result getInitAdd(
            @RequestParam(value = "status") String status
    ) {
        return systemsService.initAddSystem(status);
    }

    @ApiOperation(value = "查询类别下拉列表")
    @PostMapping(SELECT_SYSTEM_PULL_TYPE)
    public Result getSystemTypePullDown(
            @RequestBody List<String> typeId
    ) {
        return systemsService.selectTypePullDown(typeId);
    }

    @ApiOperation(value = "查询体系列表")
    @PostMapping(SELECT_SYSTEM_LIST)
    public Result getSystemsList(
            @RequestBody JSONObject json
    ) {
        int pageNum = Integer.parseInt(json.getString("pageNum"));
        int pageSize = Integer.parseInt(json.getString("pageSize"));
        String keyword = json.getString("keyword");
        return systemsService.selectSystemList(pageNum, pageSize, keyword);
    }

    @ApiOperation(value = "查询待选目标")
    @GetMapping(SELECT_SYSTEM_WAIT_CHOICE_TARGET)
    public Result getWaitChoiceTargetList(
            @RequestParam("sysId") String sysId,
            @RequestParam("keyword") String keyword
    ) {
        return systemsService.selectSystemWaitTarget(sysId, keyword);
    }

    @ApiOperation(value = "查询已选目标")
    @GetMapping(SELECT_SYSTEM_TARGET_CONFIRM)
    public Result getConfirmChoiceTargetList(
            @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
            @RequestParam(value = "pageSize", defaultValue = "5") Integer pageSize,
            @RequestParam(value = "sysId") String sysId,
            @RequestParam(value = "keyword", required = false) String keyword
    ) {
        return systemsService.selectSystemConfirmTarget(pageNum, pageSize, sysId, keyword);
    }

    //TODO: 构建体系接口

    @ApiOperation(value = "查询体系基本信息")
    @GetMapping(SELECT_SYSTEM_BASE_DATA_ONLY)
    public Result getSystemBaseData(
            @RequestParam("sysId") String sysId,
            @RequestParam(value = "redId", required = false) String redId,
            @RequestParam(value = "systemsName", required = false) String systemName,
            @RequestParam(value = "systemsType", required = false) String systemsType,
            @RequestParam(value = "remark", required = false) String remark,
            @RequestParam(value = "country", required = false) String country,
            @RequestParam(value = "keyword", required = false) String keyword,
            @RequestParam(value = "taskId", required = false) String taskId,
            @RequestParam(value = "systemType", required = false) String systemType,
            @RequestParam(value = "firstckick", required = false) Boolean judge,
            @RequestParam(value = "url", required = false) String url,
            @RequestParam(value = "countrys", required = false) String countrys,
            @RequestParam(value = "typeId", required = false, defaultValue = "") String typeId
    ) {
        return systemsService.selectSystemOnly(sysId, redId, systemName, systemsType, remark, country, keyword, taskId, systemType, judge, url, countrys, typeId);
    }

    @ApiOperation(value = "更新体系目标选择")
    @PutMapping(UPDATE_SYSTEM_TARGET_CHOICE)
    public Result getUpdateTargetChoice(
            @RequestBody JSONObject json
    ) {
        String sysId = json.getString("sysId");
        List<String> targetArray = json.getJSONArray("targetList").isEmpty() ? null : json.getJSONArray("targetList").toJavaList(String.class);
        List<String> systemArray = json.getJSONArray("systemList").isEmpty() ? null : json.getJSONArray("systemList").toJavaList(String.class);
        int type = json.getInteger("type");
        if (CollectionUtil.isEmpty(targetArray) && CollectionUtil.isEmpty(systemArray)) {
            return ResultUtil.error(500, "请选择需要添加的类型/目标");
        }
        return systemsService.addChoiceTarget(sysId, type, targetArray, systemArray);
    }

    @ApiOperation(value = "新增/更新体系基本信息")
    @PostMapping(SELECT_SYSTEM_BASE_DATA)
    public Result getAddSystem(
            @RequestBody JSONObject jsonObject,
            HttpServletResponse response
    ) {
        String sysId = jsonObject.getString("sysId");
        String redId = jsonObject.getString("redId");
        String sysName = jsonObject.getString("systemsName");
        String remark = jsonObject.getString("remark");
        String typeId = jsonObject.getString("typeId");
        String systemsType = jsonObject.getString("systemsType");
        String url = jsonObject.getString("url");
        String country = jsonObject.getString("countrys");
        if (StringUtils.isBlank(sysId)) {
            return ResultUtil.error(500, "体系ID不能为空");
        }
        if (StringUtils.isBlank(sysName)) {
            return ResultUtil.error(ResultEnum.SYSTEMS_NAME_NOT_NULL);
        }
        if (systemsService.judgeSystemsName(sysId, sysName)) {
            return ResultUtil.error(ResultEnum.SYSTEMS_NAME_EXIST);
        }
        return systemsService.addSystem(sysId, redId, sysName, typeId, remark, response.getHeader("userId"), url, country, systemsType);
    }

    //TODO: 构建体系接口 end

    @ApiOperation(value = "删除体系")
    @DeleteMapping(DELETE_SYSTEMS_BASE_DATA)
    public Result getAddSystem(
            @RequestParam("sysId") String sysId
    ) {
        if (StringUtils.isNotBlank(sysId)) {
            return systemsService.deleteSystem(Arrays.asList(sysId));
        }
        return ResultUtil.error(500, "请选择需要删除的数据");
    }

    @ApiOperation(value = "查询单个体系指标列表")
    @GetMapping(SELECT_INDEX_PULL)
    public Result getSystemIndexList(
            @RequestParam(value = "sysId") String sysId
    ) {
        return systemsService.selectIndexPull(sysId);
    }

    @ApiOperation(value = "上传目标缩略图")
    @GetMapping(UPLOAD_TARGET_ICON)
    public Result getTargetIcon(
            @RequestParam(value = "id") String id,
            @RequestParam(value = "icon") String icon,
            @RequestParam(value = "status") String status
    ) {
        switch (status) {
            case "target":
                return systemsService.uploadTargetIcon(id, icon);
            case "system":
                return systemsService.uploadSystemIcon(id, icon);
            case "rapex":
                return systemsService.uploadRapexIcon(id, icon);
            default:
                break;
        }
        return ResultUtil.error(ResultEnum.TYPE_UPLOAD_EMPTY);
    }

    @ApiOperation(value = "新增单条体系关系")
    @PostMapping(SELECT_RELATION_DATA)
    public Result<Map<String, Object>> addSystemRelationship(
            @RequestBody JSONObject json
    ) {
        return systemsService.addRelationship(json);
    }

    @ApiOperation(value = "更新单条体系关系")
    @PutMapping(SELECT_RELATION_DATA)
    public Result<Map<String, Object>> updateSystemRelationship(
            @RequestBody JSONObject json
    ) {
        return systemsService.addRelationship(json);
    }

    @ApiOperation(value = "删除单条体系关系")
    @DeleteMapping(SELECT_RELATION_DATA)
    public Result<Map<String, Object>> deleteSystemRelationship(
            @RequestParam(value = "sysShipId") String sysShipId
    ) {
        return systemsService.deleteRelationship(sysShipId);
    }

    @ApiOperation(value = "查询详细基本信息")
    @GetMapping(SELECT_SYSTEM_DETAIL_DATA)
    public Result getSystemDetailData(
            @RequestParam(value = "sysId", required = false) String sysId,
            @RequestParam(value = "targetId", required = false) String targetId
    ) {
        return systemsService.selectSystemDetail(sysId, targetId);
    }

    @ApiOperation(value = "查询体系待选信息列表")
    @GetMapping(SELECT_WAIT_DATA_LIST)
    public Result getSystemWaitDataList(
            @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
            @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize,
            @RequestParam(value = "sysId") String sysId,
            @RequestParam(value = "index", required = false) String index
    ) {
        return systemsService.selectSystemWaitList(pageNum, pageSize, sysId, index);
    }

    @ApiOperation(value = "添加待选目标到体系")
    @PostMapping(INSERT_INDEX_TARGET_LIST)
    public Result addWaitDataToConfirmData(
            @Validated @RequestBody SystemsIndexAdd systemsIndexAdd
    ) {
        return systemsService.insertConfirmIndex(systemsIndexAdd.getRelationList(), systemsIndexAdd.getSysId(), systemsIndexAdd.getStatus());
    }

    @ApiOperation(value = "查询系统已选信息列表")
    @GetMapping(SELECT_CONFIRM_DATA_LIST)
    public Result getSystemConfirmDataList(
            @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
            @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize,
            @RequestParam(value = "sysId") String sysId,
            @RequestParam(value = "index", required = false) String index
    ) {
        return systemsService.selectSystemConfirmList(pageNum, pageSize, sysId, index);
    }

    @ApiOperation(value = "查询指数列表")
    @GetMapping(SELECT_INDEX_DATA)
    public Result selectIndexData(
            @RequestParam(value = "sysId") String sysId
    ) {
        return systemsService.selectSystemIndexList(sysId);
    }

    @ApiOperation(value = "查询对比指数列表")
    @GetMapping(SELECT_INDEX_COMPARISON_DATA)
    public Result selectIndexComparisonData(
            @RequestParam(value = "sysId") String sysId
    ) {
        return systemsService.selectSystemsIndexComparisonList(sysId);
    }

    @ApiOperation(value = "查询已选目标")
    @GetMapping(SELECTED_TARGET_WUHAN)
    public Result getConfirmChoiceTargetListWuHan(
            @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
            @RequestParam(value = "pageSize", defaultValue = "5") Integer pageSize,
            @RequestParam(value = "sysId") String sysId,
            @RequestParam(value = "targetId") String targetId,
            @RequestParam(value = "keyword", required = false) String keyword
    ) {
        return systemsService.selectSystemConfirmTargetWuHan(pageNum, pageSize, sysId, targetId, keyword);
    }

    @ApiOperation(value = "新增/更新体系基本信息")
    @PostMapping(INSERT_SYSTEMS)
    public Result getAddSystemWuHan(
            @Validated @RequestBody SystemsAdd systemsAdd
    ) {
        return systemsService.addSystemWuHan(systemsAdd, systemsAdd.getTaskId());
    }

    @ApiOperation(value = "查询体系列表")
    @PostMapping(SELECT_SYSTEMS_LIST)
    public Result getSystemsListWuHan(
            @RequestBody JSONObject json
    ) {
        int pageNum = Integer.parseInt(json.getString("pageNum"));
        int pageSize = Integer.parseInt(json.getString("pageSize"));
        String taskId = json.getString("taskId");
        String keyword = json.getString("keyword");
        List<String> includeType = json.getJSONArray("includeType").toJavaList(String.class);
        return systemsService.selectSystemListWuHan(pageNum, pageSize, taskId, includeType, keyword);
    }

    @ApiOperation(value = "查询目标类型选择")
    @GetMapping(SELECT_TYPE_LIST)
    public Result getTypeList(
            @RequestParam(value = "sysId", required = false) String sysId,
            @RequestParam(value = "country", required = false) String country
    ) {
        return systemsService.selectTypeList(country, sysId);
    }

    @ApiOperation(value = "查询系统类型选择")
    @PostMapping(SELECT_SYSTEM_CHOOSE_LIST)
    public Result getSystemList(
            @RequestBody JSONObject jsonObject
    ) {
        String sysId = jsonObject.getString("sysId");
        List<String> typeList = null;
        if (CollectionUtil.isNotEmpty(jsonObject.getJSONArray("typeList"))) {
            typeList = jsonObject.getJSONArray("typeList").toJavaList(String.class);
        }
        String country = jsonObject.getString("country");
        return systemsService.selectSystemList(sysId, typeList, country);
    }

    @ApiOperation(value = "查询体系专有属性")
    @GetMapping(SYSTEMS_ELSE_DATA)
    public Result selectSystemsElseData(
            @RequestParam(value = "sysId") String sysId
    ) {
        return systemsService.selectSystemsElseData(sysId);
    }

    @ApiOperation(value = "新增/更新体系专有属性")
    @PostMapping(SYSTEMS_ELSE_DATA)
    public Result addSystemsElseData(
            @Validated @RequestBody SystemsElseAdd elseAdd
    ) {
        return systemsService.addSystemsElseData(elseAdd.getSysId(), elseAdd.getSystemsList());
    }

    @ApiOperation(value = "生成报告")
    @GetMapping(CREATE_DOC)
    public Result createDoc(
            @RequestParam(value = "sysId") String sId,
            @RequestParam(value = "damage") String damage
    ) {
        return systemsService.createDoc(sId, damage);
    }

    @ApiOperation(value = "下载报告")
    @GetMapping(DOWNLOAD_DOC)
    public Result downDoc(
            @RequestParam(value = "sysId") String sId
    ) {
        return systemsService.downDoc(sId);
    }

    @ApiOperation(value = "目标下拉")
    @GetMapping(SELECT_TARGET_PULL)
    public Result selectTargetPull(
            @RequestParam(value = "sysId") String sysId,
            @RequestParam(value = "targetId", required = false) String targetId
    ) {
        return systemsService.selectTargetPull(sysId, targetId);
    }

    @ApiOperation(value = "体系目标下拉")
    @GetMapping(value = SELECT_SYSTEM_TARGETS)
    public Result selectSystemsTargetPull(
            @RequestParam(value = "sysId") String sysId
    ) {
        return systemsService.selectSystemsTargetPull(sysId);
    }

    @ApiOperation(value = "新增打击评估")
    @PostMapping(value = ADD_BLOW)
    public Result addBlow(
            @RequestBody JSONObject json
    ) {
        return systemsService.addBlows(json);
    }

    @PostMapping(value = SYSTEMS_RANGE_DEL)
    @ApiOperation(value = "操作作用范围")
    public Result systemRangeDeo(@RequestBody SystemsRangeVo systemsRangeVo) {
        return systemElseService.systemRangeDeo(systemsRangeVo);
    }

//    @PostMapping(value = SYSTEMS_RANGE)
//    @ApiOperation(value = "体系范围操作")
//    public Result systemsRange(@RequestBody SystemsRangeVo systemsRangeVo) {
//        if (systemsRangeVo.getJudge() && null == systemsRangeVo.getRange()) {
//            return ResultUtil.error(400, "范围参数不能为空");
//        }
//        return systemElseService.addSystemsTargetActionRange(systemsRangeVo);
//    }

    @PostMapping(value = SYSTEMS_INDEX_TARGET_LIST)
    @ApiOperation(value = "体系目标清单")
    public Result getSystemsTargetIndexList(@RequestBody JSONObject jsonObject) {
        return ResultUtil.success(systemElseService.getSystemsTargetIndexList(jsonObject.getString("sysId")));
    }

    @PostMapping(value = SYSTEM_TARGET_LIST_SORT)
    @ApiOperation(value = "体系目标清单排序")
    public Result getSystemsTargetListSort(@RequestBody JSONObject json) {
        return systemElseService.upOrDown(json.getString("sysId"), json.getString("targetId"), json.getInteger("type"));
    }

    @PostMapping(value = SYSTEMS_TYPE_INDEX)
    @ApiOperation(value = "体系类型指标")
    public Result getSystemsTypeIndex(@RequestBody JSONObject jsonObject) {
        return ResultUtil.success(systemElseService.getSystemsTypeIndex(jsonObject.getString("sysId")));
    }

    @PostMapping(value = SYSTEMS_TREE)
    @ApiOperation(value = "体系树")
    public Result selectSystemsTree(
            @RequestBody JSONObject json
    ) {
        return systemsService.selectSystemsTree(
                json.getString("keyword"),
                json.getJSONArray("systemsType"),
                json.getJSONArray("country")
        );
    }

    @PostMapping(value = SYSTEMS_SCENE)
    @ApiOperation(value = "体系场景")
    public Result addSystemsScene(
            @RequestBody JSONObject json
    ) {
        return systemsService.addSystemsScene(json);
    }

    @PostMapping(value = SYSTEMS_SCENE_GET)
    @ApiOperation(value = "获取体系场景")
    public Result getSystemsScene(@RequestBody JSONObject json) {
        return systemsService.getSystemsScene(json);
    }

    @ApiOperation(value = "体系分析数据查询")
    @PostMapping(value = SYSTEMS_ANALYSIS_DATA)
    public Result selectAysMBList(@RequestBody JSONObject json) {
        String sysId = json.getString("sysId");
        return systemElseService.selectSystemsAnalysisData(sysId);
    }

    @ApiOperation(value = "体系分析能力下拉")
    @GetMapping(value = SYSTEMS_TARGET_POWER_PULL)
    public Result selectSystemsTargetPowerPull(@RequestParam(value = "sysId", required = false, defaultValue = "0") String sysId) {
        return systemElseService.selectSystemsPowerPull(sysId);
    }

    @ApiOperation(value = "体系分析重置")
    @PostMapping(value = SYSTEMS_ANALYSIS_RESTART)
    public Result restartSystemsAnalysis(@RequestBody JSONObject json) {
        String sysId = json.getString("sysId");
        return systemElseService.restartSystemsAnalysis(sysId);
    }

    @ApiOperation(value = "体系分析目标列表")
    @PostMapping(value = SYSTEMS_TARGET_POWER_TARGET_LIST)
    public Result selectAysMBList(@RequestBody SystemsIndexPowerVo powerVo) {
        return systemElseService.selectAysMBList(powerVo);
    }

    @ApiOperation(value = "体系分析目标排序")
    @PostMapping(value = SYSTEMS_TARGET_POWER_TARGET_SORT)
    public Result aysMBSort(@RequestBody JSONObject json) {
        return systemElseService.aysMBSort(json);
    }

    @ApiOperation(value = "体系分析目标删除")
    @PostMapping(value = SYSTEMS_TARGET_POWER_TARGET_DELETE)
    public Result aysMBDelete(@RequestBody JSONObject json) {
        return systemElseService.aysMBDelete(json);
    }

    @ApiOperation(value = "移动目标清单")
    @PostMapping(value = MOVE_SYSTEMS_TARGET_LIST)
    public Result aysMBMove(@RequestBody JSONObject json) {
        return systemElseService.aysMBMove(json);
    }

    @ApiOperation(value = "查询目标清单")
    @PostMapping(value = SELECT_SYSTEMS_TARGET_LIST)
    public Result aysMBChooseList(@RequestBody JSONObject json) {
        return systemElseService.aysMBChooseList(json);
    }

    @ApiOperation(value = "目标清单排序")
    @PostMapping(value = SORT_SYSTEMS_TARGET_LIST)
    public Result aysMBChooseSort(@RequestBody JSONObject json) {
        return systemElseService.aysMBChooseSort(json);
    }

    @ApiOperation(value = "目标清单目标删除")
    @PostMapping(value = DELETE_SYSTEMS_TARGET_LIST)
    public Result aysMBChooseDelete(@RequestBody JSONObject json) {
        return systemElseService.aysMBChooseDelete(json);
    }

    @ApiOperation(value = "目标指标分析")
    @PostMapping(value = HIT_ANALYSIS)
    public Result hitAnalysis(@RequestBody JSONObject json) {
        String sysId = json.getString("sysId");
        return systemElseService.hitAnalysis(sysId);
    }

    @ApiOperation(value = "目标指标保存")
    @PostMapping(value = SAVE_ANALYSIS)
    public Result saveAnalysis(@RequestBody SystemsTargetListVo systemsTargetListVo) {
        return systemElseService.saveAnalysis(systemsTargetListVo);
    }

    @ApiOperation(value = "场景树")
    @GetMapping(value = SCENE_TREE)
    public Result selectSceneList() {
        return systemElseService.selectSceneList();
    }

    @ApiOperation(value = "场景查询")
    @GetMapping(value = SCENE_DATA)
    public Result selectSceneData(@RequestParam(value = "sceneId", defaultValue = "") String sceneId) {
        return systemElseService.selectSceneData(sceneId);
    }

    @ApiOperation(value = "更新场景目标")
    @PostMapping(value = UPDATE_SCENE_TARGET)
    public Result updateSceneTarget(@RequestBody JSONObject json) {
        return systemElseService.updateSceneTarget(json);
    }

    @ApiOperation(value = "删除场景目标")
    @PostMapping(value = DELETE_SCENE_TARGET)
    public Result deleteSceneTarget(@RequestBody JSONObject json) {
        return systemElseService.deleteSceneTarget(json);
    }

    @ApiOperation(value = "查询场景子目标下拉")
    @GetMapping(value = SELECT_SCENE_SUB_PULL)
    public Result selectSceneSubPull(@RequestParam(value = "targetId") String targetId) {
        return systemElseService.selectSceneSubPull(targetId);
    }

    @ApiOperation(value = "保存场景子目标")
    @PostMapping(value = ADD_SCENE_SUB)
    public Result addSceneSub(@RequestBody JSONObject json) {
        return systemElseService.addSceneSub(json);
    }

    @ApiOperation(value = "删除场景子目标")
    @PostMapping(value = DELETE_SCENE_SUB)
    public Result deleteSceneSub(@RequestBody JSONObject json) {
        return systemElseService.deleteSceneSub(json);
    }

    @ApiOperation(value = "保存场景能力清单")
    @PostMapping(value = SAVE_SCENE_INDEX)
    public Result saveIndexList(@RequestBody JSONObject json) {
        return systemElseService.saveIndexList(json);
    }

    @ApiOperation(value = "战斗部下拉")
    @GetMapping(value = PAYLOAD_PULL)
    public Result payloadPull(@RequestParam(value = "missileId", required = false) String missileId) {
        return systemElseService.payloadPull(missileId);
    }

    @ApiOperation(value = "弹型下拉")
    @GetMapping(value = MISSILE_PULL)
    public Result missilePull() {
        return systemElseService.missilePull();
    }

    @ApiOperation(value = "导出场景Excel文档")
    @GetMapping(value = EXPORT_SCENE_EXCEL)
    public Result exportExcel(@RequestParam(value = "sceneId", required = false) String sceneId){
        return systemElseService.exportExcel(sceneId);
    }

    @ApiOperation(value = "获取必达设施")
    @GetMapping(value = GET_HIT_TARGET)
    public Result exportExcel(){
        return systemElseService.getHitTarget();
    }

    @ApiOperation(value = "体系分析目标静态分析")
    @GetMapping(value = GET_SYSTEMS_TARGET_STATIC_ANALYSE)
    public Result getSystemsTargetStaticAnalyse(
            @RequestParam(value = "sysId") String sysId
    ){
        return systemElseService.getSystemsTargetStaticAnalyse(sysId);
    }

    @ApiOperation(value = "体系分析目标规律分析停驻目标列表")
    @GetMapping(value = GET_RULE_POSTURE_LIST)
    public Result getRulePostureList(
            @RequestParam(value = "sysId") String sysId,
            @RequestParam(value = "type") Integer type
    ) {
        return systemElseService.getSystemsRulePostureList(sysId, type);
    }

    @ApiOperation(value = "体系分析目标规律分析")
    @PostMapping(value = GET_RULE_ANALYSE)
    public Result getRulePostureList(
            @RequestBody SystemsDynamicVo systemsDynamicVo
            ) {
        return systemElseService.getSystemsRuleAnalyse(systemsDynamicVo);
    }

    @ApiOperation(value = "体系分析目标动态分析")
    @PostMapping(value = GET_ACTIVE_ANALYSE)
    public Result getSystemsActiveAnalyse(
            @RequestBody SystemsDynamicVo systemsDynamicVo
    ) {
        return systemElseService.getSystemsActiveAnalyse(systemsDynamicVo);
    }

    @ApiOperation(value = "体系分析目标意图分析")
    @PostMapping(value = GET_INTENTION_ANALYSE)
    public Result getIntentionAnalyse(
            @RequestBody SystemsDynamicVo systemsDynamicVo
    ) {
        return systemElseService.getIntentionAnalyse(systemsDynamicVo);
    }

    @ApiOperation(value = "体系分析目标关联分析")
    @PostMapping(value = GET_RELATION_ANALYSE)
    public Result getRelationAnalyse(
            @RequestBody SystemsDynamicVo systemsDynamicVo
    ) {
        return systemElseService.getRelationAnalyse(systemsDynamicVo);
    }

    @ApiOperation(value = "体系分析目标整体分析")
    @PostMapping(value = GET_OVERALL_ANALYSE)
    public Result getOverallAnalyse(
            @RequestBody SystemsDynamicVo systemsDynamicVo
    ) {
        return systemElseService.getOverallAnalyse(systemsDynamicVo);
    }

}
